package operation;

import book.BookList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a1227
 * Date: 2022-10-04
 * Time: 12:00
 */
public class ReturnOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("归还书籍！");
        System.out.println("请输入所要归还的书名:>");
        String name = scanner.nextLine();
        int i = 0;
        for(; i < bookList.getSize(); i++){
            if(name.equals(bookList.getBook(i).getName())){
                bookList.getBook(i).setState(false);
                break;
            }
        }
        if(i == bookList.getSize()){
            System.out.println("所要归还的书籍不存在！");
            return;
        }
        System.out.println("归还成功！");
        System.out.println(bookList.getBook(i));
    }
}
